//
//  LoginOtherLogin.m
//  OfficeBook
//
//  Created by 朱 琳 on 15/10/11.
//  Copyright (c) 2015年 sunny. All rights reserved.
//

#import "LoginOtherLoginViewCell.h"

@interface LoginOtherLoginViewCell()

@property (nonatomic, strong) UIButton *otherLogin1;
@property (nonatomic, strong) UIButton *otherLogin2;
@property (nonatomic, strong) UILabel *otherLabel1;
@property (nonatomic, strong) UILabel *otherLabel2;

@end

@implementation LoginOtherLoginViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    
    self.otherLogin1 = [[UIButton alloc]init];
    self.otherLogin2 = [[UIButton alloc]init];
    self.otherLabel1 = [[UILabel alloc]init];
    self.otherLabel2 = [[UILabel alloc]init];
    
    self.otherLabel1.text = @"新浪微博登录";
    self.otherLabel2.text = @"QQ账号登录";
    
    UIImage *image1 = [UIImage imageNamed:@"roomFreeMiddle"];
    UIImageView *view1 = [[UIImageView alloc]initWithImage:image1];
    [view1 setFrame:CGRectMake(0, 0, 80, 80)];
    UIImage *image2 = [UIImage imageNamed:@"roomUsedMiddle"];
    UIImageView *view2 = [[UIImageView alloc]initWithImage:image2];
    [view2 setFrame:CGRectMake(0, 0, 80, 80)];
    
    view1.contentMode =  UIViewContentModeScaleToFill;
    view2.contentMode =  UIViewContentModeScaleToFill;
    
    [self.otherLogin1 addSubview:view1];
    [self.otherLogin2 addSubview:view2];
    
    [self.contentView addSubview:self.otherLogin1];
    [self.contentView addSubview:self.otherLogin2];
    [self.contentView addSubview:self.otherLabel1];
    [self.contentView addSubview:self.otherLabel2];
    
    [self.otherLogin1 makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.contentView.centerX).offset(-80);
        make.top.equalTo(self.contentView).offset(20);
        make.width.equalTo(@80);
        make.height.equalTo(@80);
    }];
    self.otherLogin1.backgroundColor = [UIColor redColor];
    
    [self.otherLabel1 makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.otherLogin1.bottom);
        make.centerX.equalTo(self.otherLogin1);
        make.width.equalTo(@120);
        make.height.equalTo(@40);
    }];
    
    [self.otherLogin2 makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.contentView.centerX).offset(80);
        make.top.equalTo(self.contentView).offset(20);
        make.width.equalTo(@80);
        make.height.equalTo(@80);
    }];
    self.otherLogin2.backgroundColor = [UIColor redColor];
    
    [self.otherLabel2 makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.otherLogin2.bottom);
        make.centerX.equalTo(self.otherLogin2);
        make.width.equalTo(@100);
        make.height.equalTo(@40);
    }];
    
    return self;
}

- (void)drawRect:(CGRect)rect {
    CGContextRef context = UIGraphicsGetCurrentContext();
    
    CGContextSetFillColorWithColor(context, [UIColor whiteColor].CGColor);
    CGContextFillRect(context, rect);
    
    CGContextSetStrokeColorWithColor(context, [UIColor colorWithRed:0xE2/255.0f green:0xE2/255.0f blue:0xE2/255.0f alpha:1].CGColor);
    CGContextStrokeRect(context, CGRectMake(10, rect.size.height, rect.size.width - 20, 0.8));
}

@end
